<template>
	<view class="content">
		<view class="wid100 dis disAl bacFFF foSi25 fowe600" style="height: 100rpx;">
			<view class="dis disJuC hei100" style="width: 50%;">
				<view class="dis disAl disJuC" style="height: 96rpx;" @click="xuanClick(0)"
					:style="xuan == 0?'border-bottom: 4rpx solid '+theme.main_color+';color: '+theme.main_color+';':
					'border-bottom: 4rpx solid #fff;color: #737373;'">不喜欢Ta</view>
			</view>
			<view class="dis disJuC hei100" style="width: 50%;">
				<view class="dis disAl disJuC" style="height: 96rpx;" @click="xuanClick(1)"
					:style="xuan == 1?'border-bottom: 4rpx solid '+theme.main_color+';color: '+theme.main_color+';':
					'border-bottom: 4rpx solid #fff;color: #737373;'">不看Ta的作品</view>
			</view>
		</view>
		<scroll-view style="height: calc(100vh - 100rpx);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view style="height: 1rpx;"></view>
			<block v-for="(item,index) in list" :key="index">
				<view class="wid90 mar borRad20 bacFFF mar-top30" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);padding: 30rpx 0;">
					<view class="wid90 mar dis disAl disJuB">
						<view class="dis disAl">
							<image :src="item.coverimg" class="borRad50" style="width: 130rpx;height: 130rpx;"></image>
							<view class="mar-left30 foSi40 fowe600">{{item.name}}</view>
						</view>
						<view class="foSi20 dis disAl disJuC borRad40" @click="yichu(index)" 
						:style="'border: 1rpx solid '+theme.main_color+';color: '+theme.main_color+';'"
							style="width: 132rpx;height: 48rpx;">移除列表</view>
					</view>
				</view>
			</block>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				xuan: 0,
				last_page: 0,
				page: 1,
				list: [],
				theme: null
			}
		},
		onLoad() {
			this.getList()
			this.theme = uni.getStorageSync('theme')
		},
		methods: {
			yichu(index){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/usershieid/add',
					method: "POST",
					header: {
						'site-id': that.global.site_id ,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						tech_id: that.list[index].id,
						type: 2
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.list.splice(index, 1);
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
			xuanClick(index){
				if(this.xuan != index){
					this.xuan = index
					this.page = 1
					this.getList()
				}
			},
			getList(){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/usershieid/lists',
					method: "POST",
					header: {
						'site-id': that.global.site_id ,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.list = result.data
							// that.last_page = result.data.last_page
							// if(that.page == 1){
							// 	that.list = result.data.data
							// }else{
							// 	that.list = that.list.concat(result.data.data)
							// }
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
		background-color: #F2F2F2;
	}
</style>
